/**
*
* @author Anastasiya
*
*/

#include "report.h"
#include "util.h"

using namespace std;
using namespace utl;

const string ReportWriter::REPORT_VALUES_DIVIDER = "    ";

ReportWriter::ReportWriter(const bool testMode){
	this->testMode = testMode;
}

void ReportWriter::openReportFile(const string fileName){
	reportFileStream.open(fileName.c_str());
	writeHeader();
}
void ReportWriter::closeReportFile(const int processedFileCount, const int failedFileCount){
	writeStatistics(processedFileCount, failedFileCount);
	reportFileStream.flush();
	reportFileStream.close();
}
void ReportWriter::writeResultsToReport(const string fileName, const ULONGLONG executionTime, const int deletedEdgesCount){
	if(!testMode){
		return;
	}
	reportFileStream << fileName << REPORT_VALUES_DIVIDER;
	reportFileStream << numberToString(deletedEdgesCount) << REPORT_VALUES_DIVIDER;
	reportFileStream << timeToString(executionTime) << REPORT_VALUES_DIVIDER;
	reportFileStream << endl;
}

void ReportWriter::writeFailResultsToReport(const string fileName, const string failureMessage){
	reportFileStream << fileName << REPORT_VALUES_DIVIDER;
	reportFileStream << "Failed: " << failureMessage << endl;
}

void ReportWriter::writeHeader(){
	reportFileStream << "<graph name> <deleted edges count> <processing time>" << endl << endl;
}
void ReportWriter::writeStatistics(const int processedFileCount, const int failedFileCount){
	reportFileStream << endl << endl << "-----------------"<< endl;
	reportFileStream << "Processed: " << processedFileCount << endl;
	reportFileStream << "Failed: " << failedFileCount << endl;
}